<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="https://cdn.staticfile.org/jquery/3.6.0/jquery.min.js"></script>
    <script>
        $(function(){
            captchaLoad()
        })

        function captchaLoad(){
            $.ajax({
                url:'captchaImage',
                dataType:'json',
                success:function(res){
                    $('#img').attr('src',res.data.img)
                    $('#uuid').val(res.data.uuid)
                }
            })
        }

        function doSubmit(){
            $.ajax({
                type:'post',
                url:'captchaCheck',
                data:{
                    uuid:$('#uuid').val(),
                    code:$('#code').val()
                },
                dataType:'json',
                success:function(res){
                    console.log(res)
                    if(res.status != 200){
                        captchaLoad()
                    }
                }
            })
        }
    </script>
</head>
<body>
    验证码：
    <input type="text" id="code">
    <img src="" id="img" onclick="captchaLoad()">
    <input type="hidden" id="uuid">
    <button onclick="doSubmit()">提交</button>
</body>
</html>